<?php

	$user_result = mysql_query("SELECT * FROM users WHERE username='{$_SESSION['username']}'");
	$user_id = mysql_result($user_result, 0, "id");
	$hospital_id = mysql_result(mysql_query("SELECT id FROM hospitals WHERE owner_id=$user_id"), 0);	
	$numrooms = mysql_num_rows(mysql_query("SELECT id FROM rooms WHERE hospital_id=$hospital_id"));

	echo "<fieldset>";
	echo "<legend><b>Building Information</b></legend><br />";
	echo "<b><u>Rooms</u></b><ul>";
	echo "<li><b><u>Total Rooms:</u></b> $numrooms</li>";
	for ($i = 0; $i < mysql_num_rows(mysql_query("SELECT name FROM room_types")); $i++)
	{
		$result1 = mysql_query("SELECT id, name FROM room_types");
		$room_id = mysql_result($result1, $i, "id");
		$room_type = mysql_result($result1, $i, "name");
		$num = mysql_num_rows(mysql_query("SELECT id FROM rooms WHERE type_id=$room_id AND hospital_id=$hospital_id"));
		echo "<li><u>{$room_type}s:</u> $num</li>";
	}
	echo "</ul>";
	echo "<a href='index.php?view=addroom'>Buy More Rooms</a>";
	echo "<br /></fieldset>";

?>